import { OperationResult } from '../types';

/**
 * 事务操作接口
 */
export interface ITransaction {
    /** 获取事务ID */
    getId(): string;
    
    /** 开始事务 */
    begin(): Promise<void>;
    
    /** 提交事务 */
    commit(): Promise<void>;
    
    /** 回滚事务 */
    rollback(): Promise<void>;
    
    /** 执行数据库操作 */
    execute(operation: () => Promise<OperationResult>): Promise<OperationResult>;
    
    /** 获取事务状态 */
    getStatus(): TransactionStatus;
}

/**
 * 事务状态枚举
 */
export enum TransactionStatus {
    INITIAL = 'initial',
    ACTIVE = 'active',
    COMMITTED = 'committed',
    ROLLED_BACK = 'rolled_back',
    ERROR = 'error'
}
